package com.project.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.ExpertConsultation.ExpertBean;
import com.project.service.IExpertService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("expert")
public class ExpertController {

    @Resource

    private IExpertService expertService;


    @RequestMapping("findCutExpert")
    public IPage<ExpertBean> findCutExpert(@RequestParam(value = "pageNo",defaultValue = "1") int pageNo, @RequestParam(value = "pageSize",defaultValue = "3") int pageSize, String expertName, String expertSpecialty, String expertUnit) {

        IPage<ExpertBean> page = expertService.findCutExpert(pageNo,pageSize,expertName,expertSpecialty,expertUnit);

        return page;
    }

    @RequestMapping("addExpert")
    public String addExpert(ExpertBean expertBean) {
        if (expertBean!= null){
            expertService.addExpert(expertBean);
        }

        return "ok";
    }

    @RequestMapping("findExpertById")
    public ExpertBean findExpertById(int expertId) {

        ExpertBean expertBean = expertService.findExpertById(expertId);


        return expertBean;
    }

    @RequestMapping("updateExpert")
    public String updateExpert(int expertId,String expertTel,String expertJob,String expertUnit,String expertEmail) {

        expertService.updateExpert(expertId,expertTel,expertJob,expertUnit,expertEmail);

        return "ok";
    }
    @RequestMapping("delExpert")
    public String delExpert(int expertId) {

        expertService.delExpert(expertId);

        return "ok";
    }


    @RequestMapping("findAll")
    public List<ExpertBean> findAllexp(){
      List<ExpertBean> list = expertService.findAllexp();

      return list;
    }
}
